package 数值的整数次方;
//题目描述
//给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
//
//保证base和exponent不同时为0
public class Solution
{
    public double Power(double base, int exponent)
    {
       //分类，正数，负数，0
        double result=1.0;
        if (exponent==0)
            return 1.0;
        if (base==0)
            return 0.0;
        int absexponent=Math.abs(exponent);
        result=Power1(base,absexponent);
        if (exponent<0)
            result=1.0/result;
        return result;
    }
    public double Power1(double base,int exponent)
    {
        double result=1.0;
        for (int i = 0; i < exponent; i++)
        {
            result*=base;
        }
        return result;
    }

    public static void main(String[] args)
    {
        Solution solution = new Solution();
        System.out.println(solution.Power(2,-3));
    }
}
